package com.Nahida.NaHome.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.View;

import androidx.annotation.Nullable;

public class WindowView extends View {
    View.OnKeyListener onKeyListener;

    public WindowView(Context context) {
        super(context);
    }

    public WindowView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public WindowView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public void setOnKeyListener(OnKeyListener l) {
        onKeyListener = l;
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        if(this.onKeyListener != null) this.onKeyListener.onKey(this, event.getKeyCode(), event);
        return super.dispatchKeyEvent(event);
    }
}
